<template>
  <view>
    <!-- 图片 -->
    <scroll-view scroll-x class="scroll-view_H" @scroll="scroll" scroll-left="120">
      <template v-if="isShow">
        <image class="shang" v-for="(item, index) in datas[name].picUrls" :key="index" :src="'https://jxjsservice.jxfit.cn/file'+item" />
      </template>
      <template v-else>
        <image class="shang" src="../../../static/11.png" lazy-load />
      </template>
    </scroll-view>
    <view class="u-f-ac items">
      <!-- 渲染数据 -->
      <block v-for="(item, index) in list" :key="index">
        <block v-for="(item2, index2) in item.list" :key="index2">
          <view class="xia u-f-ajc">
            {{item.names}}·{{item2}}
          </view>
        </block>
      </block>
      <!-- 无数据 -->
      <template v-if="!list.length">
        <view class="xia u-f-ajc">无</view>
      </template>
    </view>
  </view>
</template>

<script>
  export default {
    props: ['datas', 'name'],
    data() {
      return {
        old: {
          scrollTop: 0
        },
        list: [],
        isShow: false,
      }
    },
    watch: {
      datas(newVal) {
        if (newVal) {
          this.computedList()
        }
      }
    },
    methods: {
      computedList() {
        if (this.datas[this.name].hasOwnProperty('picUrls') && this.datas[this.name].picUrls.length) this.isShow = true
        else this.isShow = false
        console.log('111111111', this.datas)
        let coms = (names, buwei) => {
          if (this.datas[this.name][buwei].length) {
            let list = this.datas[this.name][buwei]
            let obj = {
              names,
              list
            }
            if (buwei != 'picUrls') {
              console.log(obj)
              this.list.push(obj)
              console.log(this.list)
            }
          }
        }
        coms('全身', 'body')
        coms('头部', 'head')
        coms('肩部', 'shoulder')
        coms('颈椎', 'cervical')
        coms('肩胛骨', 'scapula')
        coms('上肢', 'upperLimb')
        coms('胸椎', 'thoracic')
        coms('胸腰椎', 'chestLumbarSpine')
        coms('腰椎', 'lumbar')
        coms('肋骨', 'ribs')
        coms('手臂', 'arm')
        coms('手部', 'hands')
        coms('骨盆', 'pelvic')
        coms('臀线', 'feet')
        coms('髋关节', 'hip')
        coms('膝关节', 'knee')
        coms('胫骨', 'tibia')
        coms('脚踝', 'ankle')
        // coms('足部', 'footer')
      },
      scroll: function(e) {
        this.old.scrollTop = e.detail.scrollTop
      },
    }
  }
</script>

<style>
</style>
